﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace PJOnimal
{
    public class ManEnd : GameScene
    {
        SpriteFont fontChu1;
        int soLuongButton = 2;
        Button[] button;
        Vector2 toaDoGoc; 

        public ManEnd(Onimal game)
            : base(game)
        {
            hinhNen = game.Content.Load<Texture2D>("HinhNen/deathnote");
            fontChu1 = game.Content.Load<SpriteFont>("Font/Font1");

            //game.dieuHanhGame.man1 = new Man1(game);

            #region Load Content và tọa độ cho button
            button = new Button[soLuongButton];
            toaDoGoc = new Vector2(5, 5);

            for (int i = 0; i < soLuongButton; i++)
            {
                button[i] = new Button(game, "menu");
                button[0].toaDo = toaDoGoc + new Vector2(0, 50);
                if (i > 0)
                    button[i].toaDo = toaDoGoc + new Vector2(0, button[i - 1].toaDo.Y + 50);

               
            }
            button[0].showText[3] = true;
            button[1].showText[2] = true;
            #endregion
        }

        public void UpdateButton(GameTime gameTime)
        {
            for (int i = 0; i < soLuongButton; i++)
            {
                button[i].Update(gameTime);
            }

            if (button[0].deChuotLen && input.NhanChuot())
            {
                
                game.dieuHanhGame.ChuyenMan(game.dieuHanhGame.end , game.dieuHanhGame.select);
            }

            if (button[1].deChuotLen && input.NhanChuot())
            {
                game.dieuHanhGame.ChuyenMan(this, game.dieuHanhGame.man1);
            }
        }

        public override void Update(GameTime gameTime)
        {
            UpdateButton(gameTime);
            base.Update(gameTime);
        }

        public override void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(hinhNen, Vector2.Zero, Color.White);

            for (int i = 0; i < soLuongButton; i++)
                button[i].Draw(spriteBatch);

            spriteBatch.DrawString(fontChu1, "Ban da chet", new Vector2(10, 330), Color.White);
            base.Draw(spriteBatch);
        }
    }
}
